package com.wc.codeforces.贪心.Two_Movies;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/6/27 23:24
 * @description https://codeforces.com/contest/1989/problem/C
 */
public class Main {
    /**
     * 思路：贪心
     * 就是说都大于0和都小于0的记录
     *
     * 细心比较
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 200010;
    static int[] a = new int[N], b = new int[N];
    static int n;

    public static void main(String[] args) {
        int T = sc.nextInt();
        while (T-- > 0) {
            n = sc.nextInt();
            for (int i = 1; i <= n; i++) a[i] = sc.nextInt();
            for (int i = 1; i <= n; i++) b[i] = sc.nextInt();
            int A = 0, B = 0;
            int allneg = 0, allpos = 0;
            for (int i = 1; i <= n; i++) {
                if (a[i] > 0 && b[i] > 0) allpos++;
                else if (a[i] > 0 && b[i] <= 0) A += 1;
                else if (b[i] > 0 && a[i] <= 0) B += 1;
                else if (a[i] < 0 && b[i] < 0) allneg++;

            }
            int res = 0;
            int sub = Math.abs(A - B);
            if (sub <= allneg) {
                allneg -= sub;
                A = B = Math.min(A, B);
            } else {
                int aa = Math.max(A, B), bb = Math.min(A, B);
                A = Math.max(A, B) - allneg;
                B = bb;
                allneg = 0;
            }
            sub = Math.abs(A - B);
            if (sub <= allpos) {
                allpos -= sub;
                A = B = Math.max(A, B);
            } else {
                int aa = Math.max(A, B), bb = Math.min(A, B);
                A = Math.min(A, B) + allpos;
                B = aa;
                allpos = 0;
            }
            if (A != B) res = Math.min(A, B);
            else {
                int com = allpos - allneg;
                if (com > 0) res = A + com / 2;
                else res = A - (-com + 1) / 2;
            }

            out.println(res);
        }
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
